package com.desmart.ht;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.unnamed.b.atv.model.TreeNode;
import com.unnamed.b.atv.view.AndroidTreeView;

public class EyeActivity extends BaseActivity implements View.OnClickListener {

    private View vBack;
    private RelativeLayout container;

    public static void start(Context context){
        Intent intent = new Intent(context,EyeActivity.class);
        context.startActivity(intent);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_eye);
        TextView tvTitle = findViewById(R.id.common_content_tv);
        vBack = findViewById(R.id.common_back_iv);
        vBack.setOnClickListener(this);
        tvTitle.setText("查看");
        initViews();
        initDatas();
    }

    private void initViews() {
        container = findViewById(R.id.container);
    }

    private void initDatas() {

        TreeNode root = TreeNode.root();
        TreeNode parent = new TreeNode(new IconTreeItemHolder.IconTreeItem("张三")).setViewHolder(new IconTreeItemHolder(this));

        TreeNode child0 = new TreeNode(new IconTreeItemHolder.IconTreeItem("王二",3,true)).setViewHolder(new IconTreeItemHolder(this));
        TreeNode child01 = new TreeNode(new IconTreeItemHolder.IconTreeItem("拜拜",5,false)).setViewHolder(new IconTreeItemHolder(this));
        TreeNode child02 = new TreeNode(new IconTreeItemHolder.IconTreeItem("你好",5,false)).setViewHolder(new IconTreeItemHolder(this));
        child0.addChildren(child01,child02);

        TreeNode child1 = new TreeNode(new IconTreeItemHolder.IconTreeItem("小三",3,true)).setViewHolder(new IconTreeItemHolder(this));
        TreeNode child11 = new TreeNode(new IconTreeItemHolder.IconTreeItem("我不是小三",5,false)).setViewHolder(new IconTreeItemHolder(this));
        child1.addChildren(child11);

        TreeNode child2 = new TreeNode(new IconTreeItemHolder.IconTreeItem("小编",3,true)).setViewHolder(new IconTreeItemHolder(this));
        TreeNode child21 = new TreeNode(new IconTreeItemHolder.IconTreeItem("小编001",5,false)).setViewHolder(new IconTreeItemHolder(this));
        TreeNode child22 = new TreeNode(new IconTreeItemHolder.IconTreeItem("小编002",5,false)).setViewHolder(new IconTreeItemHolder(this));
        TreeNode child23 = new TreeNode(new IconTreeItemHolder.IconTreeItem("小编003",5,false)).setViewHolder(new IconTreeItemHolder(this));
        TreeNode child24 = new TreeNode(new IconTreeItemHolder.IconTreeItem("小编004",5,false)).setViewHolder(new IconTreeItemHolder(this));
        TreeNode child25 = new TreeNode(new IconTreeItemHolder.IconTreeItem("小编005",5,false)).setViewHolder(new IconTreeItemHolder(this));
        child2.addChildren(child21,child22,child23,child24,child25);
        parent.addChildren(child0, child1,child2);
        root.addChild(parent);
        AndroidTreeView tView = new AndroidTreeView(this, root);
        container.addView(tView.getView());

    }

    @Override
    public void onClick(View view) {
        if (view == vBack){
            onBackPressed();
        }
    }
}
